package com.example.projetoandroid;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class CriarContaActivity extends Activity implements OnClickListener{

	UsuariosDB uDB = new UsuariosDB(this);
	Usuario u = new Usuario();
	
	EditText edtnome = (EditText)findViewById(R.id.editTextNome);
	EditText edtlogin = (EditText)findViewById(R.id.editTextUsername);
	EditText edtsenha = (EditText)findViewById(R.id.editTextSenha);
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_criar_conta);
		Button btnCreateAccount = (Button)findViewById(R.id.CreateAccount);
		btnCreateAccount.setOnClickListener(this);
	
	Bundle getArguments = new Bundle();
	u = (Usuario)getArguments.getSerializable("usuario");
	edtnome.setText(u.nome);
	edtlogin.setText(u.login);
	edtsenha.setText(u.senha);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.criar_conta, menu);
		return true;
	}

	@Override
	public void onClick(View v) {
		if(v.getId() == R.id.CreateAccount){
			
			u.nome = edtnome.getText().toString();
			u.login = edtlogin.getText().toString();
			u.senha = edtsenha.getText().toString();
			uDB.inserir(u);
		}
		
	}

	
}
